package org.syh.boyangfighthealthclub.controller;

import org.syh.boyangfighthealthclub.service.IUserService;
import org.syh.boyangfighthealthclub.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: Ben
 * @Date: 2021/3/10 18:00
 */
@WebServlet("/admin/deleteUser")
public class DeleteUser extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        res.setContentType("text/html;utf-8");
        int id= Integer.parseInt(req.getParameter("id"));
       IUserService iUserService=new UserServiceImpl();
       boolean judgment=iUserService.deleteUser(id);
       if (judgment){
         res.sendRedirect("../success.jsp");
         return;
       }
       res.sendRedirect("../fail.jsp");
    }
}
